package cn.hwadee.muying.enums;

import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;

/**
 * Created by Mankind on 2018/8/8.
 */
public enum Level implements IEnum {
    PRIMARY_NURSERY_TEACHER(1,"初级育婴师"),
    MIDDLE_NURSERY_TEACHER(2,"中级育婴师"),
    ADVANCED_NURSERY_TEACHER(3,"高级育婴师");

    private int value;
    private String desc;
    Level(final int value, final String desc){
        this.value=value;
        this.desc=desc;
    }

    @Override
    public Serializable getValue() {
        return this.value;
    }

    public int getId() {
        return this.value;
    }


    @JsonValue
    public String getDesc(){
        return this.desc;
    }

    public static Level getById(int id) {
        Level[] nurseryTeacherLevels = Level.values();
        for(Level nurseryTeacherLevel : nurseryTeacherLevels){
            if(nurseryTeacherLevel.value == id){
                return nurseryTeacherLevel;
            }
        }
        return null;
    }

    public static Level getByDesc(String desc) {
        Level[] nurseryTeacherLevels = Level.values();
        for(Level nurseryTeacherLevel : nurseryTeacherLevels){
            if(nurseryTeacherLevel.desc.equals(desc)){
                return nurseryTeacherLevel;
            }
        }
        return null;
    }
}
